
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>负载均衡-Ribbon · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sidebar-style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="10.服务调用-OpenFeign.html" />
    
    
    <link rel="prev" href="8.更换注册中心-Consul.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">基础篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../java基础/IO流基础.html">
            
                <a href="../java基础/IO流基础.html">
            
                    
                    IO流基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../java基础/集合.html">
            
                <a href="../java基础/集合.html">
            
                    
                    集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../java基础/异常处理.html">
            
                <a href="../java基础/异常处理.html">
            
                    
                    异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../java基础/线程.html">
            
                <a href="../java基础/线程.html">
            
                    
                    线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../java基础/网络编程.html">
            
                <a href="../java基础/网络编程.html">
            
                    
                    网络编程
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">进阶篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../java进阶/MySQL.html">
            
                <a href="../java进阶/MySQL.html">
            
                    
                    MySQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../java进阶/Oracle.html">
            
                <a href="../java进阶/Oracle.html">
            
                    
                    Oracle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../java进阶/Redis.html">
            
                <a href="../java进阶/Redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../java进阶/Netty.html">
            
                <a href="../java进阶/Netty.html">
            
                    
                    Netty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../java进阶/Spring.html">
            
                <a href="../java进阶/Spring.html">
            
                    
                    Spring
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../java进阶/SpringMVC.html">
            
                <a href="../java进阶/SpringMVC.html">
            
                    
                    SpringMVC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../java进阶/单元测试.html">
            
                <a href="../java进阶/单元测试.html">
            
                    
                    SpringBoot单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../java进阶/设计模式.html">
            
                <a href="../java进阶/设计模式.html">
            
                    
                    二十三个设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.8.1" data-path="../java进阶/工厂模式.html">
            
                <a href="../java进阶/工厂模式.html">
            
                    
                    工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.2" data-path="../java进阶/单例模式.html">
            
                <a href="../java进阶/单例模式.html">
            
                    
                    单例模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.3" data-path="../java进阶/建造者模式.html">
            
                <a href="../java进阶/建造者模式.html">
            
                    
                    建造者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.4" data-path="../java进阶/原型模式.html">
            
                <a href="../java进阶/原型模式.html">
            
                    
                    原型模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.5" data-path="../java进阶/适配器模式.html">
            
                <a href="../java进阶/适配器模式.html">
            
                    
                    适配器模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.6" data-path="../java进阶/责任链模式.html">
            
                <a href="../java进阶/责任链模式.html">
            
                    
                    责任链模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.7" data-path="../java进阶/桥接模式.html">
            
                <a href="../java进阶/桥接模式.html">
            
                    
                    桥接模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">高级篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="1.cloud架构选型.html">
            
                <a href="1.cloud架构选型.html">
            
                    
                    Spring Cloud
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="2.Provider-支付模块.html">
            
                <a href="2.Provider-支付模块.html">
            
                    
                    Provider-支付模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="3.Consumer-订单模块.html">
            
                <a href="3.Consumer-订单模块.html">
            
                    
                    Consumer-订单模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="4.重构-Common模块.html">
            
                <a href="4.重构-Common模块.html">
            
                    
                    重构-Common模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="5.注册中心-Enreka.html">
            
                <a href="5.注册中心-Enreka.html">
            
                    
                    注册中心-Enreka
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="6.负载均衡-@LoadBalance.html">
            
                <a href="6.负载均衡-@LoadBalance.html">
            
                    
                    负载均衡-@LoadBalance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.6" data-path="7.更换注册中心-Zookeeper.html">
            
                <a href="7.更换注册中心-Zookeeper.html">
            
                    
                    更换注册中心-Zookeeper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.7" data-path="8.更换注册中心-Consul.html">
            
                <a href="8.更换注册中心-Consul.html">
            
                    
                    更换注册中心-Consul
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="4.1.8" data-path="9.负载均衡-Ribbon.html">
            
                <a href="9.负载均衡-Ribbon.html">
            
                    
                    负载均衡-Ribbon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.9" data-path="10.服务调用-OpenFeign.html">
            
                <a href="10.服务调用-OpenFeign.html">
            
                    
                    服务调用-OpenFeign
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.10" data-path="11.熔断器-Hystrix.html">
            
                <a href="11.熔断器-Hystrix.html">
            
                    
                    熔断器-Hystrix
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.11" data-path="12.网关-Gateway.html">
            
                <a href="12.网关-Gateway.html">
            
                    
                    网关-Gateway
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.12" data-path="13.配置中心-Config.html">
            
                <a href="13.配置中心-Config.html">
            
                    
                    配置中心-Config
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.13" data-path="14.消息总线-bus.html">
            
                <a href="14.消息总线-bus.html">
            
                    
                    消息总线-Bus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.14" data-path="15.消息驱动-stream.html">
            
                <a href="15.消息驱动-stream.html">
            
                    
                    消息驱动-Stream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.15" data-path="16.链路监控-Sleuth.html">
            
                <a href="16.链路监控-Sleuth.html">
            
                    
                    链路监控-Sleuth
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.16" data-path="17.注册中心&配置中心-nacos.html">
            
                <a href="17.注册中心&配置中心-nacos.html">
            
                    
                    注册中心&配置中心-nacos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.17" data-path="18.限流-sentinel.html">
            
                <a href="18.限流-sentinel.html">
            
                    
                    限流-sentinel
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../java高级/JUC.html">
            
                <a href="../java高级/JUC.html">
            
                    
                    神秘的JUC包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../java高级/Docker.html">
            
                <a href="../java高级/Docker.html">
            
                    
                    Docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../java高级/布隆过滤器.html">
            
                <a href="../java高级/布隆过滤器.html">
            
                    
                    布隆过滤器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../java高级/Redission.html">
            
                <a href="../java高级/Redission.html">
            
                    
                    Redission
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../java高级/MQ.html">
            
                <a href="../java高级/MQ.html">
            
                    
                    消息队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="../java高级/JVM.html">
            
                <a href="../java高级/JVM.html">
            
                    
                    JVM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="../java书籍/《Effective Java》读书笔记.html">
            
                <a href="../java书籍/《Effective Java》读书笔记.html">
            
                    
                    《Effective Java》读书笔记 
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.8.1" data-path="../java书籍/创建和销毁对象.html">
            
                <a href="../java书籍/创建和销毁对象.html">
            
                    
                    创建和销毁对象
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">番外篇</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../java面试/面试题.html">
            
                <a href="../java面试/面试题.html">
            
                    
                    面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../番外篇/小程序.html">
            
                <a href="../番外篇/小程序.html">
            
                    
                    微信小程序
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >负载均衡-Ribbon</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="1ribbon&#x6982;&#x8FF0;"><a name="1ribbon&#x6982;&#x8FF0;" class="plugin-anchor" href="#1ribbon&#x6982;&#x8FF0;"><i class="fa fa-link" aria-hidden="true"></i></a>1.Ribbon&#x6982;&#x8FF0;</h3>
<p>Spring Cloud Ribbon&#x662F;&#x57FA;&#x4E8E;Netflix Ribbon&#x5B9E;&#x73B0;&#x7684;&#x4E00;&#x5957; <strong>&#x5BA2;&#x6237;&#x7AEF; </strong>&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7684;&#x5DE5;&#x5177;&#x3002;</p>
<p>&#x7B80;&#x5355;&#x7684;&#x8BF4;&#xFF0C;Ribbon&#x662F;Netflix&#x53D1; &#x5E03;&#x7684;&#x5F00;&#x6E90;&#x9879;&#x76EE;&#xFF0C;&#x4E3B;&#x8981;&#x529F;&#x80FD;&#x662F;&#x63D0;&#x4F9B;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x8F6F;&#x4EF6;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;&#x548C;&#x670D;&#x52A1;&#x8C03;&#x7528;&#x3002;Ribbon&#x5BA2;&#x6237;&#x7AEF;&#x7EC4;&#x4EF6;&#x63D0;&#x4F9B;-&#x7CFB;&#x5217;
&#x5B8C;&#x5584;&#x7684;&#x914D;&#x7F6E;&#x9879;&#x5982;&#x8FDE;&#x63A5;&#x8D85;&#x65F6;&#xFF0C;&#x91CD;&#x8BD5;&#x7B49;&#x3002;&#x7B80;&#x5355;&#x7684;&#x8BF4;&#xFF0C;&#x5C31;&#x662F;&#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x5217;&#x51FA;Load Balancer (&#x7B80;&#x79F0;LB)&#x540E;&#x9762;&#x6240;&#x6709;&#x7684;&#x673A;&#x5668;&#xFF0C;Ribbon&#x4F1A;&#x81EA;&#x52A8;&#x7684;&#x5E2E;
&#x52A9;&#x4F60;&#x57FA;&#x4E8E;&#x67D0;&#x79CD;&#x89C4;&#x5219;(&#x5982;&#x7B80;&#x5355;&#x8F6E;&#x8BE2;&#xFF0C;&#x968F;&#x673A;&#x8FDE;&#x63A5;&#x7B49;)&#x53BB;&#x8FDE;&#x63A5;&#x8FD9;&#x4E9B;&#x673A;&#x5668;&#x3002;&#x6211;&#x4EEC;&#x5F88;&#x5BB9;&#x6613;&#x4F7F;&#x7528;Ribbon&#x5B9E;&#x73B0;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;&#x3002;</p>
<p><a href="https://github.com/Netflix/ribbon/wiki/Getting-Started" target="_blank">&#x5B98;&#x65B9;&#x624B;&#x518C;</a></p>
<ul>
<li><p><strong>Ribbon&#x672C;&#x5730;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x5BA2;&#x6237;&#x7AEF;VS Nginx&#x670D;&#x52A1;&#x7AEF;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x533A;&#x522B;</strong></p>
<p>Nginx&#x662F;&#x670D;&#x52A1;&#x5668;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x6240;&#x6709;&#x8BF7;&#x6C42;&#x90FD;&#x4F1A;&#x4EA4;&#x7ED9;nginx,&#x7136;&#x540E;&#x7531;nginx&#x5B9E;&#x73B0;&#x8F6C;&#x53D1;&#x8BF7;&#x6C42;&#x3002;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x662F;&#x7531;&#x670D;&#x52A1;&#x7AEF;&#x5B9E;&#x73B0;&#x7684;&#x3002;&#xFF08;&#x5927;&#x95E8;&#x53E3;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#xFF0C;&#x96C6;&#x4E2D;&#x5F0F;LB&#xFF09;</p>
<p>Ribbon&#x672C;&#x5730;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#xFF0C;&#x5728;&#x8C03;&#x7528;&#x5FAE;&#x670D;&#x52A1;&#x63A5;&#x53E3;&#x65F6;&#x5019;&#xFF0C;&#x4F1A;&#x5728;&#x6CE8;&#x518C;&#x4E2D;&#x5FC3;&#x4E0A;&#x83B7;&#x53D6;&#x6CE8;&#x518C;&#x4FE1;&#x606F;&#x670D;&#x52A1;&#x5217;&#x8868;&#x4E4B;&#x540E;&#x7F13;&#x5B58;&#x5230;JVM&#x672C;&#x5730;&#xFF0C;&#x4ECE;&#x800C;&#x5728;&#x672C;&#x5730;&#x5B9E;&#x73B0;RPC&#x8FDC;
&#x7A0B;&#x670D;&#x52A1;&#x8C03;&#x7528;&#x6280;&#x672F;&#x3002;&#xFF08;&#x5185;&#x90E8;&#x5927;&#x95E8;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#xFF0C;&#x8FDB;&#x7A0B;&#x5185;LB&#xFF09;</p>
</li>
<li><p><strong>Ribbon&#x5982;&#x4F55;&#x5DE5;&#x4F5C;</strong></p>
<ul>
<li>&#x7B2C;&#x4E00;&#x6B65;&#x5148;&#x9009;&#x62E9;EurekaServer ,&#x5B83;&#x4F18;&#x5148;&#x9009;&#x62E9;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x533A;&#x57DF;&#x5185;&#x8D1F;&#x8F7D;&#x8F83;&#x5C11;&#x7684;server.</li>
<li>&#x7B2C;&#x4E8C;&#x6B65;&#x518D;&#x6839;&#x636E;&#x7528;&#x6237;&#x6307;&#x5B9A;&#x7684;&#x7B56;&#x7565;&#xFF0C;&#x5728;&#x4ECE;server&#x53D6;&#x5230;&#x7684;&#x670D;&#x52A1;&#x6CE8;&#x518C;&#x5217;&#x8868;&#x4E2D;&#x9009;&#x62E9;&#x4E00; &#x4E2A;&#x5730;&#x5740;&#x3002;&#x5176;&#x4E2D;Ribbon&#x63D0;&#x4F9B;&#x4E86;&#x591A;&#x79CD;&#x7B56;&#x7565;:&#x6BD4;&#x5982;&#x8F6E;&#x8BE2;&#x3001;&#x968F;&#x673A;&#x548C;&#x6839;&#x636E;&#x54CD;&#x5E94;&#x65F6;&#x95F4;&#x52A0;&#x6743;&#x3002;</li>
</ul>
</li>
</ul>
<h3 id="2&#x96C6;&#x6210;ribbon"><a name="2&#x96C6;&#x6210;ribbon" class="plugin-anchor" href="#2&#x96C6;&#x6210;ribbon"><i class="fa fa-link" aria-hidden="true"></i></a>2.&#x96C6;&#x6210;Ribbon</h3>
<p><img src="https://tva1.sinaimg.cn/large/e6c9d24ely1h2rg0ay9j2j20z20eg41z.jpg" alt="image-20220519174003330"></p>
<p>&#x200B;    &#x5F53;&#x4F60;&#x5F15;&#x5165;Eureka&#xFF0C;&#x4F60;&#x5C31;&#x5DF2;&#x7ECF;&#x5F15;&#x5165;&#x4E86;Ribbon&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x52A0;&#x4E86;@LoanBalance&#x540E;&#x53EF;&#x4EE5;&#x8D1F;&#x8F7D;&#x7684;&#x539F;&#x56E0;&#x3002;</p>
<h3 id="3ribbon&#x652F;&#x6301;&#x54EA;&#x4E9B;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;&#xFF1F;&#x5982;&#x4F55;&#x66FF;&#x6362;"><a name="3ribbon&#x652F;&#x6301;&#x54EA;&#x4E9B;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;&#xFF1F;&#x5982;&#x4F55;&#x66FF;&#x6362;" class="plugin-anchor" href="#3ribbon&#x652F;&#x6301;&#x54EA;&#x4E9B;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;&#xFF1F;&#x5982;&#x4F55;&#x66FF;&#x6362;"><i class="fa fa-link" aria-hidden="true"></i></a>3.Ribbon&#x652F;&#x6301;&#x54EA;&#x4E9B;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;&#xFF1F;&#x5982;&#x4F55;&#x66FF;&#x6362;</h3>
<ul>
<li><p>&#x652F;&#x6301;&#x7684;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;&#xFF0C;&#x4E3B;&#x8981;&#x662F;&#x901A;&#x8FC7;IRule&#x63A5;&#x53E3;&#x5B9E;&#x73B0;&#x7684;&#x3002;</p>
<ul>
<li>com.netflix.loadbalance.RoundRobinRule     &#x8F6E;&#x8BE2;</li>
<li>com.netflix.loadbalance.RandomRule            &#x968F;&#x673A;</li>
<li>com.netflix.loadbalance.RetryRule                  &#x5148;&#x6309;&#x7167;RoundRobinRule&#x7B56;&#x7565;&#x83B7;&#x53D6;&#x670D;&#x52A1;&#xFF0C;&#x5982;&#x679C;&#x83B7;&#x53D6;&#x670D;&#x52A1;&#x5931;&#x8D25;&#x5728;&#x6307;&#x5B9A;&#x7684;&#x65F6;&#x95F4;&#x5185;&#x4F1A;&#x91CD;&#x8BD5;</li>
<li>WeightedResponseTimeRule                            &#x5BF9;&#x4E8E;RoundRobinRule&#x7684;&#x6269;&#x5C55;&#xFF0C;&#x54CD;&#x5E94;&#x901F;&#x5EA6;&#x8D8A;&#x5FEB;&#x7684;&#x670D;&#x52A1;&#x6743;&#x91CD;&#x8D8A;&#x5927;</li>
<li>BaseAvailableRule                                              &#x4F1A;&#x8FC7;&#x6EE4;&#x7531;&#x4E8E;&#x591A;&#x6B21;&#x8BBF;&#x95EE;&#x6545;&#x969C;&#x800C;&#x5BFC;&#x81F4;&#x7194;&#x65AD;&#x5668;&#x8DF3;&#x95F8;&#x7684;&#x670D;&#x52A1;&#xFF0C;&#x7136;&#x540E;&#x9009;&#x62E9;&#x4E00;&#x4E2A;&#x5E76;&#x53D1;&#x91CF;&#x6700;&#x5C0F;&#x7684;</li>
<li>AvailabilityFilteringRule                                     &#x4F1A;&#x8FC7;&#x6EE4;&#x6389;&#x6545;&#x969C;&#x5B9E;&#x4F8B;&#xFF0C;&#x518D;&#x9009;&#x62E9;&#x5E76;&#x53D1;&#x91CF;&#x6700;&#x5C0F;&#x7684;&#x670D;&#x52A1;</li>
<li>ZoneAvoidanceRule                                           &#x9ED8;&#x8BA4;&#xFF0C;&#x590D;&#x5408;&#x5224;&#x65AD;Server&#x6240;&#x5728;&#x533A;&#x57DF;&#x7684;&#x6027;&#x80FD;&#x548C;&#x53EF;&#x7528;&#x6027;&#x9009;&#x62E9;&#x670D;&#x52A1;&#x5668;</li>
</ul>
</li>
<li><p>&#x5982;&#x4F55;&#x66FF;&#x6362;</p>
<p>&#x6CE8;&#x610F;&#x4FEE;&#x6539;&#x7EC6;&#x8282;&#xFF1A;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x914D;&#x7F6E;&#x7C7B;&#x4E0D;&#x80FD;&#x653E;&#x5728;<code>@ComponentScan</code>&#x626B;&#x63CF;&#x7684;&#x5305;&#x53CA;&#x5B50;&#x5305;&#x4E0B;&#xFF0C;&#x5426;&#x5219;&#x8FD9;&#x4E2A;&#x914D;&#x7F6E;&#x7C7B;&#x4F1A;&#x88AB;Ribbon&#x5BA2;&#x6237;&#x7AEF;&#x6240;&#x5171;&#x4EAB;&#x8FBE;&#x4E0D;&#x5230;&#x5B9A;&#x5236;&#x5316;&#x3002;&#x5982;&#x4E0B;<code>@SpringBootApplication</code>&#x4E2D;&#x5C31;&#x5305;&#x62EC;&#x4E86;<code>@ComponentScan</code>&#xFF0C;&#x6240;&#x4EE5;&#x5728;&#x542F;&#x52A8;&#x7C7B;&#x6240;&#x5728;&#x7684;&#x5305;&#x53CA;&#x5B50;&#x5305;&#x4E0B;&#x90FD;&#x4E0D;&#x53EF;&#x4EE5;&#x3002;</p>
</li>
</ul>
<pre><code class="lang-java">
  <span class="hljs-meta">@Target</span>({ElementType.TYPE})
  <span class="hljs-meta">@Retention</span>(RetentionPolicy.RUNTIME)
  <span class="hljs-meta">@Documented</span>
  <span class="hljs-meta">@Inherited</span>
  <span class="hljs-meta">@SpringBootConfiguration</span>
  <span class="hljs-meta">@EnableAutoConfiguration</span>
  <span class="hljs-meta">@ComponentScan</span>(
      excludeFilters = {<span class="hljs-meta">@Filter</span>(
      type = FilterType.CUSTOM,
      classes = {TypeExcludeFilter.class}
  ), <span class="hljs-meta">@Filter</span>(
      type = FilterType.CUSTOM,
      classes = {AutoConfigurationExcludeFilter.class}
  )}
  )
  <span class="hljs-keyword">public</span> <span class="hljs-meta">@interface</span> SpringBootApplication {
      <span class="hljs-comment">//....</span>
  }
</code></pre>
<p>  &#x4FEE;&#x6539;<strong>&#x6D88;&#x8D39;&#x8005;</strong>&#x81EA;&#x5B9A;&#x4E49;&#x81EA;&#x5DF1;&#x7684;&#x89C4;&#x5219;&#x7C7B;</p>
<pre><code class="lang-java">  <span class="hljs-meta">@Configuration</span>
  <span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MySelfRule</span> </span>{
      <span class="hljs-meta">@Bean</span>
      <span class="hljs-function"><span class="hljs-keyword">public</span> IRule <span class="hljs-title">myRule</span><span class="hljs-params">()</span> </span>{
          <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> RandomRule();<span class="hljs-comment">//&#x5B9A;&#x4E49;&#x4E3A;&#x968F;&#x673A;    </span>
      }
  }
</code></pre>
<p>  &#x4FEE;&#x6539;<strong>&#x6D88;&#x8D39;&#x8005;</strong>&#x544A;&#x8BC9;Ribbion&#x4F7F;&#x7528;&#x6211;&#x81EA;&#x5DF1;&#x5199;&#x7684;&#x89C4;&#x5219;</p>
<pre><code class="lang-java">  <span class="hljs-meta">@EnableEurekaClient</span>
  <span class="hljs-meta">@SpringBootApplication</span>
  <span class="hljs-meta">@RibbonClient</span>(name = <span class="hljs-string">&quot;&#x670D;&#x52A1;&#x540D;&quot;</span>,configuration = MySelfRule.class)
  <span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">OrderMain80</span> </span>{    
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{        
      SpringApplication.run(OrderMain80.class,args);    
    }
  }
</code></pre>
<h3 id="4&#x8F6E;&#x8BE2;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;"><a name="4&#x8F6E;&#x8BE2;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;" class="plugin-anchor" href="#4&#x8F6E;&#x8BE2;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>4.&#x8F6E;&#x8BE2;&#x8D1F;&#x8F7D;&#x5747;&#x8861;&#x7B97;&#x6CD5;</h3>
<ul>
<li><p>&#x63A5;&#x53E3;&#x8BF7;&#x6C42;&#x6B21;&#x6570;%&#x8BE5;&#x670D;&#x52A1;&#x5B9E;&#x4F8B;&#x6570;=&#x96C6;&#x7FA4;&#x5217;&#x8868;&#x7684;&#x5143;&#x7D20;&#x4E0B;&#x6807;</p>
<pre><code class="lang-java"><span class="hljs-comment">//&#x83B7;&#x53D6;&#x670D;&#x52A1;&#x5217;&#x8868;</span>
List&lt;ServiceInstance&gt; instances = discoveryClient.getInstance(<span class="hljs-string">&quot;&#x670D;&#x52A1;&#x540D;&quot;</span>);
</code></pre>
</li>
</ul>
<p>&#x200B;    </p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; mine 2022-2025 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2022-07-07 15:26:16
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="8.更换注册中心-Consul.html" class="navigation navigation-prev " aria-label="Previous page: 更换注册中心-Consul">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="10.服务调用-OpenFeign.html" class="navigation navigation-next " aria-label="Next page: 服务调用-OpenFeign">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"负载均衡-Ribbon","level":"4.1.8","depth":2,"next":{"title":"服务调用-OpenFeign","level":"4.1.9","depth":2,"path":"springcloud/10.服务调用-OpenFeign.md","ref":"springcloud/10.服务调用-OpenFeign.md","articles":[]},"previous":{"title":"更换注册中心-Consul","level":"4.1.7","depth":2,"path":"springcloud/8.更换注册中心-Consul.md","ref":"springcloud/8.更换注册中心-Consul.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["back-to-top-button","code","splitter","expandable-chapters-small","anchors","theme-comscore","tbfed-pagefooter","sidebar-style","pageview-count","popup"],"pluginsConfig":{"sidebar-style":{"author":"梁兴龙","title":"《Java 笔记本》"},"tbfed-pagefooter":{"copyright":"Copyright &copy mine 2022-2025","modify_label":"文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"splitter":{},"search":{},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"back-to-top-button":{},"pageview-count":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"springcloud/9.负载均衡-Ribbon.md","mtime":"2022-07-07T07:26:16.146Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-08-22T03:22:22.085Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sidebar-style/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

